import { post, get, del } from '@/utils/http'
import { jsonToSearch } from '@/utils/tools'

// export const getRolesApi = (page = 1) => get(`/api/roles?page=${page}`)
// export const addRoleApi = roleData => post(`/api/roles`, roleData)

// export const roleidToAuthsApi = roleid => get(`/api/roleidToAuths/${roleid}`)

// 管理员用户
// export const adminUserApi = () => get(`/rooms/useradmin`)


//111
export const adminUserApi = (page = 1, searchData = null, pagesize = 10) => {
    if (searchData === null) {
      return get(`/rooms/useradmin?page=${page}&pagesize=${pagesize}`)
    }
    // typeof toString
    // let searchStr = Object.keys(searchData)
    //   .map(key => `${key}=${searchData[key]}`)
    //   .join('&')
    let searchStr = jsonToSearch(searchData)
    return get(`/rooms/useradmin?page=${page}&pagesize=${pagesize}&${searchStr}`)
  }
  //添加管理员
  export const addAdminUserApi = userData => post(`/rooms/useradmin`, userData)
  //删除管理员
  export const removeUidToUserApi = usernum => del(`/rooms/useradmin/${usernum}`)
  // 根据用户id，返回对应用户信息
  export const getUidToUserApi = usernum => get(`/rooms/useradmin/${usernum}`)
